<?php

namespace App\Controller\Admin;

use App\Entity\Conference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/admin/rs")
 * Class AdminController
 * @package App\Controller
 */
class RsAdminController extends BaseController
{
    /**
     * @Route("/conference/exit/{slug}",name="rs_admin_conference_exit")
     */
    public function ConferenceIndex(Request $request,Conference $conference)
    {
        $form = $this->createForm("App\Form\ConferenceFormType",$conference);
        $form->handleRequest($request);
        if($request->isMethod("POST")){
            $em = $this->container->get('doctrine')->getManager();
            $em->persist($conference);
            $em->flush();
            return $this->redirectToRoute("admin_conference_list");
        }
        if($error = $form->getErrors(true)->current())return new Response($error->getMessage());
        $this->parameters['form'] =$form->createView();
        return $this->render("admin/exit/conference.html.twig",$this->parameters);
    }

}